package com.itheima.demo;

import com.itheima.domain.Item;
import com.itheima.domain.Order;
import com.itheima.domain.User;
import com.itheima.mapper.UsersMapper;
import com.itheima.utils.MapperUtil;
import org.apache.ibatis.session.SqlSession;


import java.util.List;

public class Demo {
    public static void main(String[] args) {
        /*UsersMapper mapper = MapperUtil.getMapper(UsersMapper.class);
        List<User> list = mapper.findUser();*/
        SqlSession session = MapperUtil.getSession();
        List<User> list = session.selectList("com.itheima.mapper.UsersMapper.findUser");
        //System.out.println(list);
        for (User user : list) {
            System.out.println("用户名: " + user.getName());
            List<Order> orderList = user.getOrderList();
            for (Order order : orderList) {
                System.out.println("订单编号: " + order.getNumber());
                List<Item> itemList = order.getItemList();
                for (Item item : itemList) {
                    System.out.println("商品名称: " + item.getName());
                }
            }
        }
    }
}
